package cn.loveq.android.comment;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import cn.loveq.android.R;
import cn.loveq.android.model.Comment;

/**
 * 
 * 
 * 项目名称：loveq4Weibo 
 * 类名称：CommentActivity 
 * 类描述： 主持人互动评论类 
 * 创建人：李伟豪
 *  创建时间：2011-12-3 下午08:57:09 
 *  修改人：Administrator 
 *  修改时间：2011-12-3 下午08:57:09 
 *  修改备注：
 * 
 * @version
 * 
 */
public class CommentActivity extends Activity {
	// 数组
	private CommentAdapter adapter;
	private Activity mActivity;
	private ListView commentListView;
	private ArrayList<Comment> list;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.comment);
	}

	public class CommentAdapter extends BaseAdapter {
		private int mImageViewClickPosition;
		private LayoutInflater mInflater;
		private Context mContext;
		private ViewHolder2Comment holder;

		public CommentAdapter(Context c) {
			mContext = c;
			mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		}

		@Override
		public int getCount() {
			return list.size();
		}

		@Override
		public Object getItem(int position) {
			return list.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView != null) {
				holder = (ViewHolder2Comment) convertView.getTag();
			} else {
				convertView = mInflater.inflate(R.xml.item_comment, null);
				holder = new ViewHolder2Comment();
				// holder.tv_history_name = (TextView) convertView.findViewById(R.id.tv_history_name);
				// holder.tv_history_time = (TextView) convertView.findViewById(R.id.tv_history_time);
				// holder.lv_iv_dustbin = (ImageView) convertView.findViewById(R.id.lv_iv_dustbin);
				convertView.setTag(holder);
			}

			holder.position = position;// 获取每个item位置

			if (list != null) {
				holder.tv_history_name.setText(list.get(position).getCommenter());
				holder.tv_history_time.setText(list.get(position).getCommentContent());
			}
			return convertView;
		}

		public ViewHolder2Comment getViewHolder(View v) {
			if (v.getTag() == null) {
				return getViewHolder((View) v.getParent());
			}
			return (ViewHolder2Comment) v.getTag();
		}

	}

	/**
	 * ListView的评论信息的ID持有类
	 */
	class ViewHolder2Comment {
		TextView tv_history_time;
		TextView tv_history_name;
		ImageView lv_iv_dustbin;
		int position;
	}

}
